home *** CD-ROM | disk | FTP | other *** search
- /* internal header file for implementations of sortlist
- functions */
-
- #if !defined(SLINTRNL_H)
- #define SLINTRNL_H
-
- #include "align.h"
-
- /* the beginning part of a node in the AVL tree. after this
- structure comes the element that is associated with the
- node. */
- typedef struct
- {
- /* balance factor */
- char balance;
- /* pointer to each branch */
- void *(branch[2]);
- }
- NODE_PREFIX;
-
- #define N_UNITS_IN_NODE_PREFIX N_ALIGN_UNITS(sizeof(NODE_PREFIX))
-
- /* return address of element within a tree node */
- #define ELEM_IN_NODE(NODE) \
- ((void *) (((ALIGN_TYPE *) (NODE)) + N_UNITS_IN_NODE_PREFIX))
-
- /* macro to cast a void pointer to a pointer to node prefix */
- #define NODE(VP) ((NODE_PREFIX *) (VP))
-
- /* indeces into branch array in NODE_PREFIX for the two branches */
- #define LESS_BRANCH 0
- #define GREATER_BRANCH 1
-
- /* macro returning the other branch. that is, it returns LESS_BRANCH
- for input of GREATER_BRANCH and vis-versa */
- #define OTHER(THIS) (1 - (THIS))
-
- /* balance an unbalanced tree. returns non-zero if depth
- of tree reduced by 1, otherwise 0. */
- int balance_tree
- (
- /* pointer to pointer to subtree of sorted list to balance */
- void **t
- );
-
- #endif
-